{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:url('save')}">
        <input type="hidden" name="id" value="{:isset($vo.id)?$vo.id:''}">
        <input type="hidden" name="name"  value="{$vo.name ?? ''}"  >
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>品牌名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
            	<input type="text" datatype="*" name='name' class="input-text"  value="{$vo.name ?? ''}" placeholder="" >
                <span></span>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>名称首字母：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" datatype="*" name='initial' class="input-text"  value="{$vo.initial ?? ''}" placeholder="" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">展示方式：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="show_type" id="show_type-1" value="0" >
                    <label for="show_type-1">图片</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="show_type" id="show_type-0" value="1">
                    <label for="show_type-0">文字</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="form form-horizontal" id="brand_pic" style="display:none">
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">图片：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" name="pic" value="{$vo.pic|default=''}" id="upload" placeholder="请点击后面的上传按钮" nullmsg="请填写图片url" style="width: 70%">
                    <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload\'])}')">上传</button>
                    <a onclick="$(this).attr('href', $('#upload').val())" type="button" class="btn btn-success radius" data-lightbox="preview">预览</a>
                </div>
                <div class="col-xs-3 col-sm-3"></div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">是否推荐：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="recommend" id="recommend-1" value="1" datatype="*" >
                    <label for="recommend-1">推荐</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="recommend" id="recommend-0" value="0">
                    <label for="recommend-0">不推荐</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">排序：</label>
            <div class="formControls col-xs-6 col-sm-6">
            	<input type="text" name='sort' class="input-text"  value="{$vo.sort ?? ''}" placeholder="255" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='recommend'][value='{$vo.recommend==1 ? 1 : 0}']").attr("checked", true);
        $("[name='show_type'][value='{$vo.show_type==1 ? 1 : 0}']").attr("checked", true);
        if(parseInt($("[name='show_type']:checked").val()) == 0){
            $('#brand_pic').show();
        }
        $("[name='show_type']").change(function(){
            $('#brand_pic').toggle();
        });
        
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret) {
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}